Part Number Hot Search : 
KSB772Y ISD231X BS108 HC5242 2SD24 SRAF0560 033RDA1 2SK19
Product Description
Full Text Search
 

To Download AN594 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  application note t.castagnet / j. nicolai / n. michel ? AN594 / 04,93 direct software lcd drive with st621x and st626x introduction this note describes a technique for driving a liquid crystal display (lcd) with a standard st62 microcon- troller (mcu), without any dedicated lcd driver. this technique offers a display c apability for applications which require a small display at a low cost together with the versatile capabilities of the standard st62xx mcu. higher display requirements are easilyhandled by dedicated members of the st62 mcu family, for example the st6240. the first part of this note describes the typical waveforms required to drive an lcd correctly with a multi- plexing rate of 1 or 2 (duplex). the following parts present two solutions based on standard st62 mcus driving directly the lcd. the first is based on an st6215 without using software interrupts and the second on an st6265 where the lcd is controlled by timer interrupts. in both examples the programsize, the cpu time occupation due to the lcd drive and the number of surround- ing components are minimized. consequently many additionaltasks can be added to the mcu program. lcd requirements with a zero root mean square (rms) voltage applied to it, an lcd is practically transparent. the lcd contrast, which makes the segments turn dark or opaque and thus aono, is caused by the difference be- tween the rms lcd voltage applied and the lcd threshold voltage, specific to each lcd type. the applied lcd voltage must alternate to give a zero dc value in order to ensure a long life time of the lcd. the higher the multiplexing rate is, the lower the contrast, also the period of the signal has to be short enough to avoid visible flickering of the lcd display. the lcd voltage for each segment equals to the difference between the s and com voltages (see figure 1). figure 1. equivalent electrical schematic of an lcd segment - dc value should never be more than 100mv. else time life can be shorten. - frequency range is 30 - 2000hz typically. less, it flickers; more, consumption grows. 1/26
direct lcd drive each lcd segment is connected to an i/o asegmento and to one backplane common to all the segments. a display using s segments is driven with s+1 mcu output lines. the backplane is driven with a signal acomo controlled between 0 and v dd with a duty cycle of 50%. when selecting a segment aono, a signal with opposite polarity to acomo is sent to the corresponding aseg- mento pin. when the non-inverted signal acomo is sent to the asegmento pin, the segment is aoffo. using an mcu the i/o operate in output mode either at the logic levels 0 or 1. figure 2. lcd signals for direct drive ? direct lcd drive 2/26
duplexed lcd drive for duplexed drive, two backplanes are used in- stead of one. each lcd pin is connected to two lcd segments, each one connected on the other side to one of the two backplanes. thus, only (s/2)+2 mcu pins are necessary to drive an lcd with s segments. three different voltage levels have to be generated on the backplanes : 0, v dd /2 and v dd . the aseg- mento voltage levels are 0 and vdd only. the lcd segment is inactive if the rms voltage is below the lcd threshold voltage and is active if the lcd rms voltage is above the threshold voltage. fig- ure 4 shows typical backplane, segment and lcd waveforms. the intermediate voltage v dd /2 is only required for the abackplaneo voltages. the st62 i/o pins se- lected as abackplaneso are set by software to out- put mode for 0 or vdd levels and to high impedance input mode for v dd /2. this voltage vdd/2 is defined by two equal valued resistors ex- ternally connected to the i/o pin. by using an mcu with flexible i/o pin configuration such as the st6215 or st6265, duplexed lcd drive can be made with only 4 additional resistors. figure 3. basic lcd segment connection in duplexed mode ? direct lcd drive 3/26
figure 4. lcd signals for duplexed mode (used in st6215 example) ? direct lcd drive 4/26
example of duplexed lcd drive with st6215 the following example describes the drive in duplexed mode of an lcd with an st6215. the software is made in such way that no interrupt is generated and an off state for the lcd is possible. the only com- ponents necessary are those to drive the st62 (oscillator, reset,...) and four resistors to generate the back- plane intermediate voltages. the st6215 has 20 i/o pins, thus it is able to drive up to 36 lcd segments and 2 backplanes. one digit is defined with 8 segments connected to 2 backplanes. each digit can display 11 values, from 0 to 9 and no display. each value to be displayed is associated to a certain lcd waveform. one lcd waveform period is sepa- rated in 4 steps corresponding to the 3 i/o configurations (1-0-input). a look-up table stores the bytes which relate the i/o configuration to the value to display. figure 5. st6215 based example ? direct lcd drive 5/26
the following tables show an example of linking one lcd digit of the display with the relevant mcu port sequences. the second digit follows the same scheme. these examples are for the sample lcd display, please adapt these tables to your particular lcd. the digit segments are connected to pb0-pb3 lines in this example. schematic is shown in figure 5. each digit configuration defines a segment status. each couple of segments defines a timing sequence to be output by mcu asegmento lines (see figure 4). these sequences are coded inside the st6215. table 1: example of drive of a digit with st6215 digit segments to display segment connections segment line pb3 pb2 pb1 pb0 com1 (pa6) d e f a com2 (pa7) off c g b a fb e c g d digit required segments status com1 on on on on mcu output sequences com2 off on off on timing sequences t1 0 0 0 0 0h t2 0 1 0 1 5h t3 1 0 1 0 ah t4 1 1 1 1 fh digit required segments status com1 off off off off mcu output sequences com2 off on off on timing sequences t1 1 1 1 1 fh t2 1 0 1 0 5h t3 0 1 0 1 ah t4 0 0 0 0 0h digit required segments status com1 on on off on mcu output sequences com2 off off on on timing sequences t1 0 0 1 0 2h t2 0 0 1 1 3h t3 1100 ch t4 1101 dh digit required segments status com1 on off off on mcu output sequences com2 off on on on timing sequences t1 0 1 1 0 6h t2 0 1 1 1 7h t3 1 0 0 0 8h t4 1 0 0 1 9h digit required segments status blank com1 off off off off mcu output sequences com2 off off off off timing sequences t1 1111 fh t2 0000 0h t3 1111 fh t4 0000 0h digit required segments status com1 off off on off mcu output sequences com2 off on on on timing sequences t1 1101 dh t2 0111 7h t3 1000 8h t4 0010 2h digit required segments status com1 on off on on mcu output sequences com2 off on on off timing sequences t1 0100 4h t2 0110 6h t3 1001 9h t4 1011 bh digit required segments status com1 on on on on mcu output sequences com2 off on on off timing sequences t1 0000 0h t2 0110 6h t3 1001 9h t4 1111 fh ? direct lcd drive 6/26
digit required segments status com1 off off off on mcu output sequences com2 off on off on timing sequences t1 1 1 1 0 eh t2 0 1 0 1 5h t3 1 0 1 0 ah t4 0 0 0 1 1h digit required segments status com1 on on on on mcu output sequences com2 off on on on timing sequences t1 0 0 0 0 0h t2 0 1 1 1 7h t3 1 0 0 0 8h t4 1 1 1 1 fh digit required segments status com1 on off on on mcu output sequences com2 off on on on timing sequences t1 0100 4h t2 0111 7h t3 1000 8h t4 1011 bh ? direct lcd drive 7/26
figure 6. st6265 based example example of duplexed lcd drive with st6265 in this example the lcd drive tasks are controlled by interrupts from an on-chip timer. this software block can be easily included in a central task such as motor control, temperature measurement or heating. figure 6 shows the circuit of the application. only 4 resistors are added to drive the lcd in the duplexed mode. ? direct lcd drive 8/26
the software for the lcd display operates in interrupt mode, driving i/o pins by the cpu at instants defined by the timer1 interrupts. when the lcd drive tasks are finished, the main application program can con- tinue. the major tasks of the lcd display routine are: - generation of the alternate signals which control the backplanes (pb0, pb1) - drive of the lcd segments through porta - conversion of the hexadecimal data to decimal data - program timer1 for the next drive sequence the backplane pattern sequences are different between st6215 and st6265 examples. the st6215 soft- ware is based on non-symetrical signals (see figure 4). the backplane patterns are symetrical in the st6265 software. both are equivalent on the lcd viewpoint. the rom code size used is 300 bytes for the program and 256 bytes for the tables. with an cpu frequency of 8mhz, the display task duration is 240 m s and the full task durationincluding decimal conversion is 510 m s. with an lcd period signal of 14ms, the cpu duty cycle of occupation is 2.5% for the lcd drive task. the program can be adjusted to other applications by modifying the timer duration (fastim) and the segment drive byte table. the lcd drive phase may also be synchronized to the mains zero crossing or a software loop duration, saving the timer for other tasks. summary the examples presented in this note show that a simple lcd can be driven directly by standard st621x/2x/6x/9x microcontrollers. the st62's flexible i/o configuration and the large voltage range of op- eration of the st62 family mcu allow an lcd driver to be achieved with very few surrounding components, small cpu time occupation and reduced rom program size. such an approach is a very cost effective solution for simple lcd displays operating with a mult iplexing rate of 1 or 2 and up to 36 segments. for lcds requiring more segment drive capability and/or higher multiplex- ing rates st624x and st628x provide highly integrated and easy to implement solutions. such lcd drive features can easily beincluded in a larger application including keyboard interface, sensor display or motor control. we thank the company akotronic for the st6215 application example they havedeveloped for this note. annex 1: software of the st6215 based application annex 2: flowchart and software of the st6265 based application ? direct lcd drive 9/26
;*************************************************************************** ;*demonstration software for management of a biplexed liquid cristal ;*display ( lcd ) with st621x or st622x sgs thomson microcontrollers ;*************************************************************************** ;* this program has been developped by akotronic comp. ;* parc de la mothe 03400 yzeure france ;*************************************************************************** ;* program for liquid cristal display drive ;*************************************************************************** ;* register declaration ;*************************************************************************** .romsize 4 . vers ast6225o ; swd, 4mhz x .def 80h!m ; index register y .def 81h!m ; index register v .def 82h ; short direct register w .def 83h ; sh ort direct register a .def 0ffh!m ; accumulator dra .def 0c0h ; port a data register drb .def 0c1h ; port b data register drc .def 0c2h ; port c data register ddra .def 0c4h ; port a direction register ddrb .def 0c5h ; port b direction register ddrc .def 0c6h ; port c direction register ior .def 0c8h ; interrupt option register dwr .def 0c9h ; data rom window register ora .def 0cch ; port a option register orb .def 0cdh ; port b option register orc .def 0ceh ; port c option register adr .def 0d0h ; a/d data r egister adcr .def 0d1h ; a/d control register psc .def 0d2h ; timer prescaler register tcr .def 0d3h ; timer counter register tscr .def 0d4h ; timer status control register wdr .def 0d8h ; watchdog register ;************************************************************************** ;* data declaration ;************************************************************************** touchu .def 084h ;low s ignificant digit button ( l.s. digit ) touchd .def 085h ;more significant digit button ( m.s. digit ) touch .def 086h ;pushed button copya .def 087h ;copy of port a copyb .def 088h ;copy of port b copyc .def 089h ;copy of port c tabd .def 08ah ;data/rom window address to display m.s. digit tabu .def 08bh ;data/rom window address to display l.s. digit loop .def 08ch ;loop relache.def 08dh ;latch counter touchp .def 08eh ;previous valided button flags .def 08fh ;flags : 0/ push on/off ;************************************************************************** annex 1: software of the st6215 based application ? direct lcd drive 10/26
;************************************************************************** ;* table 1 of the low significant digit ( l.s. digit ) ;************************************************************************** .org 0f00h .byte 00fh,09fh,06fh,0ffh,0ffh,09fh,06fh,00fh .byte 04fh,0cfh,03fh,0bfh,05fh,0dfh,02fh,0afh .byte 0bfh,0dfh,02fh,04fh,01fh,05fh,0afh,0efh .byte 00fh,05fh,0afh,0ffh,07fh,09fh,06fh,08fh .byte 00fh,0dfh,02fh,0ffh,01fh,0dfh,02fh,0efh .byte 00h,00h,00h,00h,00h,00h,00h,00h .byte 00h,00h,00h,00h,00h,00h,00h,00h .byte 00h,00h,00h,00h,00h,00h,00h,00h ;************************************************************************** ;************************************************************************** ;* table 2 of the more s ignificant digit ( m.s. di git ) ;************************************************************************** .org 0f40h .byte 0ffh,0f0h,0ffh,0f0h,0ffh,0f5h,0fah,0f0h .byte 0f2h,0f3h,0fch,0fdh,0f6h,0f7h,0f8h,0f9h .byte 0fdh,0f7h,0f8h,0f2h,0f4h,0f6h,0f9h,0fbh .byte 0f0h,0f6h,0f9h,0ffh,0feh,0f5h,0fah,0f1h .byte 0f0h,0f7h,0f8h,0ffh,0f4h,0f7h,0f8h,0fbh .byte 00h,00h,00h,00h,00h,00h,00h,00h .byte 00h,00h,00h,00h,00h,00h,00h,00h .byte 00h,00h,00h,00h,00h,00h,00h,00h ;************************************************************************** ;************************************************************************** ;* interrupt vectors ;************************************************************************** .org 0ff0h it_adc nop reti it_timer jp t_it_timer it_portbc jp t_itpbc it_porta jp t_itpa nop nop nop nop nmi nop reti res jp debut ;************************************************************************** annex 1: software of the st6215 based application (continued ) ? direct lcd drive 11/26
;************************************************************************** ;* initialization subroutine ;************************************************************************** .org 880h debut reti ; end of reset interrupt ldi ddra,0c7h ; a0 to a2 push p ull output = 0 ldi ora,0c7h ; a3 to a5 pull up in put ; a6 & a7 output = 0 ldi dra,00h ; a3 to a5 for ke yboard ; a6 -> bp1, a7 -> bp2 ldi copya,00h ldi ddrb,0ffh ; b0 a b7 push pull o utput = 0 ldi orb,0ffh ; port b controls lc display ldi drb,00h ; ldi copyb,00h ; ldi ddrc,00h ; ldi orc,00h ; c4 c5 c6 c7 unu sed inputs ldi drc,00h ; ldi copyc,00h ; ldi dwr,3ch ; origin of the table ldi flags,00h ; reset flags ;************************************************************************** ;* end of initialization subroutine ;************************************************************************** ;************************************************************************** ;* main lcd dr ive subroutine ;* ;* task : generate alternative signals to control lcd backplanes bp1/bp2 ;* drive the segments of the lcd ;* calculate duration of each duration phase ;************************************************************************** sommeil res 0,flags ldi ora,0cfh ; a3 becomes interrupt input ldi ior,10h ; valid interrupt stop ; wait at on/off button activation ldi ora,0c7h ; clr ior ; inihibit interrupts call clavier ; keyboard test jrr 0,flags,sommeil ; if no push on on/off button , then stand by i1boucle res 0,flags ; else initialization of main loop ldi touchu,00h ; on/off flag is reset, unitee a 0 ldi touchd,00h ; reset m.s. digit ldi ior,10h ; valid interrupts ;************************************************************************** boucle1 ldi tcr,18 ; initialization of timer ldi tscr,7fh ; program it at 1,5 ms ld a,touchu ; determine data/rom window address sla a ; sla a ; multiply touchu by 4 ld tabu,a ; initialize data/rom address ld a,touchd ; of tables 1 & 2 sla a ; sla a ; ld tabd,a ; call datalcd ; determine segments driver byte for phase 1 ldi ora,47h ; bp1 = vdd ; bp2 = vdd/2 t herefore ldi ddra,47h ; a6 becomes push pull output at v dd ldi dra,0c0h ; a7 becomes high impedance input ld drb,a ; load segments driver byte on port call clavier ; test of keyboard wait ;*************************************************************************** annex 1: software of the st6215 based application (continued ) ? direct lcd drive 12/26
boucle2 ldi tcr,18 ; timer initialization ldi tscr,7fh ; program it at 1.5 ms inc tabu ; determine data/rom window address inc tabd ; of tables 1 & 2 for phase 2 call datalcd ; determine segments driver byte for phase 2 ldi ora,07h ; bp1 = vdd/2 ; bp2 = vss therefore ldi dra,40h ldi ddra,87h ; a6 becomes high impedance input ldi ora,87h ; & a7 becomes push pull output at vss ld drb,a ; load segments driver byte on port wait ;************************************************************************** boucle3 ldi tcr,18 ; timer initialization ldi tscr,7fh ; program it at 1.5 ms inc tabu ; determine data/rom window address inc tabd ; of tables 1 & 2 for phase 2 call datalcd ; determine segments driver byte for phase 3 ldi dra,0c0h ; bp1 = vdd/2 ; bp2 = vdd therefore ; a6 remains high impedance input ; a7 becomes push pull output at vdd ld drb,a ; load segments driver byte on port wait ;************************************************************************** boucle4 ldi tcr,18 ; timer initialization ldi tscr,7fh ; program it at 1.5 ms inc tabu ; determine data/rom window address inc tabd ; of tables 1 & 2 for phase 2 call datalcd ; determine segments driver byte for phase 4 ldi ora,07h ; bp1 = vss ; bp2 =a vdd/2 therefore ldi dra,80h ldi ddra,47h ; a6 becomes output at vss ldi ora,47h ; a7 becomes high impedance input ld drb,a ; load segments driver byte on port wait ;************************************************************************** finboucle jrr 0,flags,boucle1 ;if on/off button remains pushed, ; then circuit is in stand by & display is ; else continue digits display ldi dra,00h ldi ddra,0c7h ldi ora,0c7h ; bp1 & bp2 on output to vss ldi drb,00h prepsomm call clavier ; test of keyboard ld a,touch cpi a,0ah ; wait falling edge of on/off button jrz prepsomm ; before stop display mode jp sommeil ;************************************************************************** ;* end of main program ;************************************************************************** annex 1: software of the st6215 based application (continued ) ? direct lcd drive 13/26
;************************************************************************** ;* table subroutine ;* ;* task : define lcd segments driver byte to load on port b ;* tabu defines half driver byte for l.s.digit ;* tabd defines half driver byte for m.s.digit ;************************************************************************** datalcd ldi dwr,3ch ; move data/rom window to l.s.digit table 2 ldi a,40h add a,tabu ld x,a ld a,(x) ld y,a ; half segment driver byte is loaded ldi dwr,3dh ; move data/rom window to m.s.digit table 1 ldi a,40h add a,tabd ld x,a ld a,(x) and a,y ; lcd driver byte is loaded in accumulator ret ;************************************************************************** ;* end of table s ubroutine ;************************************************************************** ;************************************************************************** ;* keyboard subroutine ;* ;* task : controls display operation ;* searchs touchu (l.s.digit) & touchd (m.s.digit) displayed data ;* ;************************************************************************** clavier ldi loop,02h clavier1 ld a,dra andi a,38h cpi a,38h ; test 2 times if some buttons are pushed jrnz clavier2 ; if yes then check them ( a3 -> a5 ) dec loop jrnz clavier1 ldi touch,0ffh jp clavier4 ; else test if keyboard is changed clavier2 ld y,a ld a,dra andi a,38h cp a,y jrz tstcol ; if check is ok , then d etermine column ldi touch,0ffh jp clavier4 ; else test if one button was pushed tstcol jrr 3,y,col1 ; if a3 = 0 then column #1 jrr 4,y,col2 ; if a4 = 0 then column #2 col3 ldi touch,3 ; else column #3 is selected so touch <=3 jp tstlign col2 ldi touch,2 ;column #2 so touch <=2 jp tstlign col1 ldi touch,1 ;column #1 so touch <=1 annex 1: software of the st6215 based application (continued ) ? direct lcd drive 14/26
tstlign res 0,ora ; res 1,ora ; res 2,ora ; a0, a1 & a2 become open drain output res 0,ddra ; res 1,ddra ; res 2,ddra ; then pull up input set 3,ddra; set 4,ddra; set 5,ddra ; a3, a4 & a5 become open drain output set 3,ora ; set 4,ora ; set 5,ora ; then push pull output at vss ld a,dra andi a,07h jrr 0,a,lign2 ; if a0 = 0 then row #2 jrr 1,a,lign3 ; if a1 = 0 then row #3 jrr 2,a,lign4 ; if a2 = 0 then row #4 lign1 jp clavier3 ; else row #1 is selected & touch unchanged lign2 ld a,touch addi a,3 ld touch,a ; row #2 so touch ? touch + 3 jp clavier3 lign3 ld a,touch addi a,6 ld touch,a ; row #3 so touch ? touch + 6 jp clavier3 lign4 jrs 0,touch,onoff1 ldi touch,00h jp clavier3 onoff1 ldi touch,0ah ; touch ? 0ah means action on on/off button clavier3 res 3,ora ; res 4,ora ; res 5,ora ; a3, a4 & a5 become open drain ouput res 3,ddra ; res 4,ddra ; res 5,ddra ; then pull up inputs set 0,ddra ; set 1,ddra ; set 2,ddra ; a0, a1 & a2 become open drain output set 0,ora; set 1,ora; set 2,ora ; then push pull output at vss clavier4 ld a,touch cp a,touchp jrnz clavier5 jp finclav ; if unchanged state keyboard then end clavier5 ld touchp,a ; else touchp ? touch cpi a,0ffh jrnz clavier7 ; if any keyboard buttons are pushed jp finclav ; then end of subroutine clavier7 cpi a,0ah ; else test on/off button jrz onoff2 ; if yes then set flags ld a,touchu ; else shift keyboard value ld touchd,a; ld a,touch; ld touchu,a ; to be displayed jp finclav onoff2 set 0,flags finclav ret ;************************************************************************* ;* end of key board subroutine ;************************************************************************* annex 1: software of the st6215 based application (continued ) ? direct lcd drive 15/26
;************************************************************************** ;* port a int errupt subroutine ;************************************************************************** t_itpa nop reti ;************************************************************************** ;* end of port a interrupt subroutine ;************************************************************************** ;************************************************************************** ;* other interrupts subroutine ;************************************************************************** t_it_timer ldi tscr,00h reti t_itpbc nop reti ;************************************************************************** annex 1: software of the st6215 based application (continued ) ? direct lcd drive 16/26
timer_1 interrupt reload timer_1 end of interrupt program backplanes pb0= hi-z pb1= 0 program segments update segments driver byte program backplanes pb0= 0 pb1= hi-z update segments driver byte program backplanes pb0= hi-z pb1= 1 update segments driver byte convert in decimal mode program backplanes pb0= 1 pb1= hi-z update segments driver byte is loop 1 ? is loop 2 ? is loop 3 ? phase 1 phase 2 phase 3 phase 4 no (*) (*) (*) (*) (*) (*) : subroutine task yes no yes yes no vr001862 annex 2: flowchart of the st6265 based application ? direct lcd drive 17/26
;************************************************************************* ;* sgs thomson microelectronics ;* ;* central applications laboratory ;* ;* rousset france ;* ;************************************************************************** ;************************************************************************** ;* ;* 19 feb 1993 ;* ;* ;* ;* lcd005 ;* ;************************************************************************** ;************************************************************************** ;* lcd driver software program ;* st62e65 ;* duplexed control of 2 digits with port a; ;* pa0 to pa3 for digit1;pa4 to pa7 for digit2; ;* bacplanes on pb0 & pb1 ;* ;* with 4 phase s equences generator ;* with h exadecimal/decimal data conversion ;* ;************************************************************************** ;************************************************************************** ;* st6265/6 registers declaration ;************************************************************************** x .def 80h ; index register. y .def 81h ; index register. v .def 82h ; short direct register. w .def 83h ; short direct register. a .def 0ffh ; accumulator. pa .def 0c0h ; port a data register. pb .def 0c1h ; port b data register. pc .def 0c2h ; port c data register. padir .def 0c4h ; port a direction register. pbdir .def 0c5h ; port b direction register. pcdir .def 0c6h ; port c direction register. paopt .def 0cch ; port a option register. pbopt .def 0cdh ; port b option register. pcopt .def 0ceh ; port c option register. ior .def 0c8h ; interrupt option register. drwr .def 0c9h ; data rom window register. adc .def 0d0h ; a/d result register. adcc .def 0d1h ; a/d control register. psc1 .def 0d2h ; timer 1 prescaler register. tcr1 .def 0d3h ; timer 1 counter register. tscr1 .def 0d4h ; timer 1 status control register. annex 2: software of the st6265 based application ? direct lcd drive 18/26
annex 2: software of the st6265 based application (continued) mc .def 0d5h ; timer 2 mode control register. sc0 .def 0d6h ; timer 2 status/control register. sc1 .def 0d7h ; timer 2 status/control register. rc .def 0d9h ; timer 2 reload/capture register. cp .def 0dah ; timer 2 compare register. lr .def 0dbh ; timer 2 load register. wdt .def 0d8h ; watchdog register. oscr .def 0dch ; oscillator control register. lvi .def 0ddh ; multiplex register / lvi flag register. spirad .def 0e0h ; spi register rad. spidiv .def 0e1h ; spi register div. spimod .def 0e2h ; spi register mod. mbr .def 0e8h ; memory bank register. eecr .def 0eah ; eeprom control register. ;************************************************************************ ;* ram data definition ;************************************************************************ duty0 .def 087h,0ffh,0ffh ; user request reference counter1 .def 089h,0ffh,0ffh ; duty0 variation rate control byte dig1 .def 0a6h,0ffh,0ffh ; data/rom @ of digit1 segment driver dig2 .def 0a7h,0ffh,0ffh ; data/rom @ of digit2 segment driver lcdctl .def 0a8h,0ffh,0ffh ; lcd phase sequence control byte pbbuf .def 0aah,0ffh,0ffh ; buffer byte of data port b bcd .def 0a9h,0ffh,0ffh ; bincoddec converted data aux1 .def 0a3h,0ffh,0ffh ; accumulator save byte aux2 .def 0a4h,0ffh,0ffh ; data/rom window register save byte aux3 .def 0a5h,0ffh,0ffh ; x register save byte ;************************************************************************ ;* equates definition ;************************************************************************ fastim .equ 036h ; duration of each lcd drive phase (14 ms at 8 mhz) ;************************************************************************ ;************************************************************************ ;* macrofunctions definition ;************************************************************************ .macro jumpnc jpadress,?lbl jrc lbl jp jpadress lbl .endm ;************************************************************************ .macro jumpz jpadress,?lbl jrnz lbl jp jpadress lbl .endm ;************************************************************************ ? direct lcd drive 19/26
annex 2: software of the st6265 based application (continued) ;************************************************************************ ;* interrupt vectors ;************************************************************************ .org 0ff0h it_tim1 jp lcd_lp ; timer1 interrupt synchronizes lcd drive it_tim2 nop ; it.timer2 reti it_pc_spi nop ; it.port c & spi reti it_pa_pb nop ; it. port a & port b reti nop nop nop nop nmi nop reti res jp start ;*********************************************************************** ;* main program example ;*********************************************************************** .org 0880h start reti ; end of reset in terrupt call init main call duty0 jp main ;*********************************************************************** ;* end of main program ;*********************************************************************** ;*********************************************************************** ;* main initialization subroutine ;*********************************************************************** init ldi wdt,00000111b ; watchdog initialization ldi eecr,040h ; eeprom in stand by for power saving ldi oscr,008h ; ckout output disabled for power saving ldi pbdir,00110000b ; b0 & b1 is common :hi/impedance input ldi pbopt,00110000b ; b2 &b3 is input for +/- push b utton ldi pbbuf,00000011b ; pb buffer byte load ldi pb,00000011b ; b6,b7 in input with pull up ldi padir,0ffh ; a0 to a7 in push pull o utput ldi paopt,0ffh ; pa = driver of lcd segments ldi pa,00h ; output is zero ldi pcdir,00h ; ldi pcopt,00h ; c0 -> c7 inputs with pull up ldi pc,00h ; ldi drwr,3ch ; data/rom window origin clr lcdctl ; clear lcd phase sequence control ldi ior , 010h ; interrupt validation ldi tcr1 ,009h ; load timer1 for lcd phase generation ldi tscr1,07fh ; timer initialization clr duty0 ldi wdt, 00000111b ; hello watchdog ret ;*********************************************************************** ;* end of main initialization ;*********************************************************************** ? direct lcd drive 20/26
annex 2: software of the st6265 based application (continued) ;************************************************************************ ;* main task example : acquisition of user speed reference duty0 * ;* * ;* duty0 is a user reference that can vary from 0 to 255d * ;************************************************************************ duty0 jrr 2,pb,slower ; if pb2=0,then slower ; priority on slower jrr 3,pb,faster ; if pb3=0,then faster ; else continue ret ; if pb2 & pb3 are high; then continue slower ld a,duty0 cpi a,000h jumpz retour ld a,counter1 addi a,01h ld counter1,a jumpnc retour dec duty0 ; increment duty cycle ret faster ld a,duty0 cpi a,0ffh jrz retour ld a,counter1 addi a,01h ld counter1, a jrnc retour inc duty0 ; decrement duty cycle retour ret ;*********************************************************************** ;* end subroutine get_dut0 ;*********************************************************************** ;*********************************************************************** ;* duplexed lcd driver interrupt subroutine ;* ;* task : generate alternative signals of lcd backplanes control ;* drive the segments of lcd through port a ;* calculate duration of each lcd phase ;* ;*********************************************************************** lcd_lp ldi wdt,0ffh ; hello watchdog ; ld aux1, a ; | ; ld a, x ; | save context of main task (if needed) ; ld aux3, a ; | ; ldi tscr1,00h ; timer stop (if needed) ldi tcr1 , fastim ; lcd phase duration calculation ldi tscr1, 07fh ; timer initialization ;************************************************************************ ;* lcd phase generation can be here syn chronized by other clock system. ;* for instance : mains voltage synchronization or external clock ;************************************************************************ jrr 0,lcdctl,loop1; determine phase1 operation jrr 1,lcdctl,loop2; determine phase2 operation jrr 2,lcdctl,loop3; determine phase3 operation ? direct lcd drive 21/26
annex 2: software of the st6265 based application (continued) ;************************* phase 4 ********************************* loop4 inc dig1 ; increment dig1 & dig2 for phase 4 inc dig2 ; call datalcd ; calculate phase4 segments driver byte ldi pbbuf,00000011b ; pb buffer load ldi pb ,00000011b ; pb1 in high impedance (hi) & pb0 to 0 ldi pbdir,00110001b ; ldi pbbuf,00000010b ; pb buffer load ldi pb ,00000010b ; ld pa,a ; load segment driver byte on port a ld a,aux3 ;| ld x,a ;| ld a,aux2 ;|return to main tasks with context ; ld drwr,a ;| ( aux2 <== drwr in main program ); ld a,aux1 ;| clr lcdctl ; end of loop4 & full lcd sequence reti ;************************* phase 3 ******************************** loop3 inc dig1 ; increment dig1 & dig2 for phase 3 inc dig2 call datalcd ; calculate phase3 segments driver byte ldi pbopt,00110000b ; pb0 in hi & pb1 to 0 ldi pbdir,00110010b ; ldi pbbuf,00000001b ; pb buffer load ldi pb, 00000001b ; ld pa ,a ; load segment driver byte on port a ; ld a,aux3 ;| ; ld x,a ;| ; ld a,aux2 ;|return to main tasks with context ; ld drwr,a ;| ( aux2 <== drwr in main program ) ; ld a,aux1 ;| set 2,lcdctl ; end of loop3 reti ;************************* phase 2 ********************************* loop2 inc dig1 ; increment dig1 & dig2 for phase 2 inc dig2 call datalcd ; calculate phase2 segments driver byte ldi pbopt,00110000b ; pb1 in hi & pb0 to 1 ldi pbdir,00110001b ; ldi pbopt,00110001b ; ld pa,a ; load segment driver byte on port a ; ld a,aux3 ;| ; ld x,a ;| ; ld a,aux2 ;|return to main tasks with context ; ld drwr,a ;| ( aux2 <== drwr in main program ) ; ld a,aux1 ;| set 1,lcdctl ; end of loop2 reti ? direct lcd drive 22/26
;************************* phase 1 ********************************* loop1 call decconv ; do hexa-decimal data conversion call datalcd ; calculate phase1 segment driver byte ; driver data is stored in accumulator ldi pbbuf,00000011b ; pb buffer load ldi pb,00000011b ; b1 to 1 & b0 in hi ldi pbdir,00110010b ; b2 e > b7 unchanged ldi pbopt,00110010b ; ld pa,a ;load segment driver byte on port a ; ld a,aux3 ; ; ld x,a ; ; ld a,aux2 ; return to main tasks with context ; ld drwr,a ;(aux2 <== drwr in main program) ; ld a,aux1 ; set 0,lcdctl ; end of loop1 reti ;************************************************************************ ;* end of lcd dri ver subroutine ;************************************************************************ ;************************************************************************ ;* dec data/lcd segmemts conversion subroutine ;* ;* task : calculate the segments driver byte of the lcd ;* depends on the displayed data and on the # of p hase ;* based on dig1 & dig2 ca lculation ;* lcd segments driver full byte is in accumulator ;************************************************************************ datalcd ldi drwr,3ch ; move data/rom window on digit2 table ld a,dig2 ld x,a ld a,(x) ld y,a ; load digit2 driver half byte (msb) ldi drwr,3dh ; move data/rom window on digit1 table ld a,dig1 ld x,a ld a,(x) and a,y ; load digit1 driver half byte (lsb) ret ;************************************************************************ ;* end of data/lcd conversion subroutine ;************************************************************************ annex 2: software of the st6265 based application (continued) ? direct lcd drive 23/26
;************************************************************************ ;* hexadecimal e > decimal data conversion subroutine ;* ;* task : convert an hexadecimal data in a binary coded decimal data ;* determine data/rom window address of segments driver byte ;* ;* ;* hexadecimal data is a stable data varying from 0 to 256 ;* result is a percent decimal data varying from 0 to 99 ;* bcd binary coded decimal data ;* ;* for instance, data is duty0 ;* ;* dig1 = data/rom wdw @ of digit1 segments driver = 01wxyzab ;* digit1 = wxyz ( from 0 to 9 ) and ;* ab are defined by phase operation : ab = 00 for phase1 ... ;* ab = 11 for pha se4 ;* dig2 = data/rom wdxw @ of digit2 segments driver ;* similar writing than dig1 ;* ;************************************************************************* decconv jrr 7,duty0,et1 ; data <== duty0 ldi drwr,039h ; b7 of data is 1 : 50 < data < 99 jp et2 et1 ldi drwr,038h ; b7 of data is 0 : 00 < data < 49 et2 ld a,duty0 ; rlc a ; rlc a ; rlc a ; calculation of bincoddec data rlc a ; address rlc a ; rlc a ; rlc a ; rlc a ; set 6,a ; res 7,a ; ld x,a ; ld a,(x) ; ld bcd,a ; bcd <= binary coded decimal data andi a,00fh ; determine digit1 value and the sla a ; data/rom address of digit1 segments sla a ; driver addi a,040h ; ld dig1,a ; dig1 = data/rom @ of segment driver ld a,bcd ; determine digit2 value and the andi a,0f0h ; data/rom address of digit2 segments rlc a ; driver rlc a ; rlc a ; rlc a ; rlc a ; sla a ; sla a ; addi a,040h ; ld dig2,a ; dig2 = data/rom @ of lcd driver ret ;*********************************************************************** ;* end of hexa e > de cimal data conversion subroutine ;*********************************************************************** annex 2: software of the st6265 based application (continued) ? direct lcd drive 24/26
;*********************************************************************** ;* table of hexa e > decimal data conversion ( 00 to 49 b incoddec ) ;*********************************************************************** .org 0e00h .byte 00h,01h,02h,02h,03h,04h,05h,05h .byte 06h,07h,08h,09h,09h,10h,11h,12h .byte 12h,13h,14h,15h,16h,16h,17h,18h .byte 19h,20h,20h,21h,22h,23h,23h,24h .byte 25h,26h,27h,27h,28h,29h,30h,30h .byte 31h,32h,33h,34h,34h,35h,36h,37h .byte 37h,38h,39h,40h,41h,41h,42h,43h .byte 44h,45h,45h,46h,47h,48h,48h,49h ;*********************************************************************** ;* end of hexa e> decimal data conversion table ( 00 to 49 ) ;*********************************************************************** ;*********************************************************************** ;* table of hexa e> decimal data conversion ( 50 to 99 bincoddec ) ;*********************************************************************** .org 0e40h .byte 50h,51h,52h,52h,53h,54h,55h,55h .byte 56h,57h,58h,59h,59h,60h,61h,62h .byte 62h,63h,64h,65h,66h,66h,67h,68h .byte 69h,70h,70h,71h,72h,73h,73h,74h .byte 75h,76h,77h,77h,78h,79h,80h,80h .byte 81h,82h,83h,84h,84h,85h,86h,87h .byte 88h,88h,89h,90h,91h,91h,92h,93h .byte 94h,95h,95h,96h,97h,98h,98h,99h ;*********************************************************************** ;* end of hexa e > decimal data conversion table ( 50 to 99 ) ;*********************************************************************** ;*********************************************************************** ;* segment control without any point display ;*pa0,4 e-> seg cb ;*pa1,5 e-> seg dh ;*pa2,6 e-> seg dh ;*pa3,7 e-> seg ga ;* ;*pa0,pa1,pa2,pa3e-> digit1 ;*pa4,pa5,pa6,pa7e-> digit2 ;* ;*backplane #1 (pb1) biases c,d,e,g ;*backplane #2 (pb0) biases a,b,f,h ;* ;*these tables are dedicated to one lcd type with two di gits and lcd ;*control is described above ; when lcd is changing these tables have ;* to be modified a fb e c g d annex 2: software of the st6265 based application (continued) ? direct lcd drive 25/26
;************************************************************************ ;* digit2 table ;************************************************************************ .org 0f00h .byte 08fh,02fh,07fh,0dfh,0efh,0efh,01fh,01fh .byte 01fh,06fh,0efh,09fh,04fh,06fh,0bfh,09fh .byte 06fh,0afh,09fh,05fh,04fh,03fh,0bfh,0cfh .byte 00fh,03fh,0ffh,0cfh,0efh,06fh,01fh,09fh .byte 00fh,02fh,0ffh,0dfh,04fh,02fh,0bfh,0dfh .byte 0ffh,0ffh,00fh,00fh,000h,000h,000h,000h .byte 000h,000h,000h,000h,000h,000h,000h,000h .byte 000h,000h,000h,000h,000h,000h,000h,000h ;************************************************************************ ;* digit1 table ;************************************************************************ .org 0f40h .byte 0f8h,0f2h,0f7h,0fdh,0feh,0feh,0f1h,0f1h .byte 0f1h,0f6h,0feh,0f9h,0f4h,0f6h,0fbh,0f9h .byte 0f6h,0fah,0f9h,0f5h,0f4h,0f3h,0fbh,0fch .byte 0f0h,0f3h,0ffh,0fch,0feh,0f6h,0f1h,0f9h .byte 0f0h,0f2h,0ffh,0fdh,0f4h,0f2h,0fbh,0fdh .byte 0ffh,0ffh,0f0h,0f0h,000h,000h,000h,000h .byte 000h,000h,000h,000h,000h,000h,000h,000h .byte 000h,000h,000h,000h,000h,000h,000h,000h ;************************************************************************* annex 2: software of the st6265 based application (continued) information furnished is believed to be accurate and reliable. however, sgs-thomson microelectronics assumes no responsability for the consequencesof use of such information nor for any infringement of pat- ents or other rights of third parties which may result from its use. no license is granted by implication or otherwise under any patent or patent rights of sgs-thomson microelectronics. specificationsmentioned in this publication are subject to change without notice. this publication supersedes and replaces all infor- mation previously supplied. sgs-thomson microelectronics products are not authorized for use as critical components in life support devices or systems without the express written approval of sgs-thomson microelectronics. ? 1994 sgs-thomson microelectronics - all rights reserved. purchase of i 2 c components by sgs-thomson microelectronics conveys a license under the philips i 2 c patent. rights to use these components in an i 2 c system is granted provided that the system conforms to the i 2 c standard specification as defined by philips. sgs-thomson microelectronics group of companies australia - brazil - france - germany - hong kong - italy - japan - korea - malaysia - malta - morocco - the netherlands singapore - spain - sweden - switzerland - taiwan - thailand - united kingdom - u.s.a. the software included in this note is for guidance only. sgs-thomson shall not be held liable for any direct, indirect or consequential damages with respect to any claims arising from use of the software. ? direct lcd drive 26/26


▲Up To Search▲   

 
Price & Availability of AN594

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X